package com.fx.educms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fx.commonuntils.ReturnMessage;
import com.fx.commonuntils.ReturnMessageUtils;
import com.fx.educms.entity.CrmBanner;
import com.fx.educms.mapper.CrmAdminMapper;
import com.fx.educms.service.CrmAdminService;
import com.fx.educms.service.CrmFrountService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 首页banner表 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2020-11-12
 */
@Service
public class CrmFountServiceImpl extends ServiceImpl<CrmAdminMapper, CrmBanner> implements CrmFrountService {




    //注意使用ReturnMessageUntils需要无参构造器进行反序列化否则报错
    @Cacheable(value = "banner",key = "'selectIndexList'")
    @Override
    public ReturnMessage<Object> selectAllBanner() {

        QueryWrapper<CrmBanner> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("id");
        wrapper.last("limit 2");
        List<CrmBanner> list = this.list(wrapper);


        return ReturnMessageUtils.success(list);
    }
}
